using System;
namespace Foundry.Graphics
{
	public abstract class RenderDevice : IDisposable
	{
		
		[ThreadStatic]
		private static RenderDevice current_device;
		
		public static RenderDevice CurrentDevice
		{
			get
			{
				return current_device;
			}
			set
			{
				if(current_device != null)
					current_device.Dispose();
				current_device = value;
			}
		}
		
		public RenderDevice ()
		{
			// We do not like multiple rendering devices per thread
			// therefore we simply cannot allow such nonsense.
			if(current_device != null)
				throw new InvalidOperationException("There can only be one rendering device per thread.");
			
			current_device = this;
		}
		
	
		public abstract void Dispose()
		{
		}
	}
}

